Function.prototype.xjhApply = function (thisArg, arg) {
  var fn = this;
  thisArg = thisArg ? Object(thisArg) : window;
  thisArg.fn = fn;
  const result = thisArg.fn(...arg);
  delete thisArg.fn;
  return result;
};

function num(num1, num2) {
  let ret = num1 + num2;
  console.log(this, ret);
  return ret;
}

let obj = {
  name: "xjh",
};
// let obj = "xjh";
// let obj = 123;
// let obj = true;
// let obj = null;

// let ret = num.apply(obj, [1, 2]);
let ret = num.xjhApply(obj, [1, 2]);
console.log(ret);
